﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Presentacion.Resources;
using Microsoft.Live;
using Microsoft.Live.Controls;
using System.Windows.Media.Imaging;


namespace Presentacion
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor

        LiveConnectClient client;

        public MainPage()
        {
            InitializeComponent();
            SetUnderline();

           
            // Código de ejemplo para traducir ApplicationBar
            //BuildLocalizedApplicationBar();
           
        }


        private void SetUnderline()
        {
            MasTarde.TextDecorations = TextDecorations.Underline;
        }

       

        private async void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
        {
            if (e.Status == LiveConnectSessionStatus.Connected)
            {        
                client = new LiveConnectClient(e.Session);
                LiveOperationResult operationResult = await client.GetAsync("me");
                try
                { 
                    dynamic meResult = operationResult.Result;
                    if (meResult.first_name != null &&
                        meResult.last_name != null)
                    {
                        infoTextBlock.Text = "Hello " +
                            meResult.first_name + " " +
                            meResult.last_name + "!";
                    }
                    else
                    {
                        infoTextBlock.Text = "Hello, signed-in user!";
                    }
                }
                catch (LiveConnectException exception)
                {
                    this.infoTextBlock.Text = "Error calling API: " +
                        exception.Message;
                }
            }
            else
            {
                infoTextBlock.Text = "Not signed in.";
            }
        }

        private void MasTarde_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {

        }
    }
           
        }
    